from django.conf import settings
from django.core.mail import send_mail


def send_resetpwd_email(to_email, context):

    subject = "博学谷密码重置"  # 邮件标题
    message = ''  # 普通邮件正文，普通字符串
    from_email = settings.EMAIL_FROM  # 发件人
    recipient_list = [to_email] # 收件人列表

    # 多媒体邮件正文，可以是html字符串
    html_message = f"<p>尊敬的用户您好！</p>" \
                   f"<p>感谢您使用博学谷。</p>" \
                   f"<p>您的邮箱为：{to_email}请点击此链接重置您的登陆密码：</p>" \
                   f'<p><a href="{context}">{context}<a></p>' \
                   f"<p>感谢您使用博学谷。</p>"

    send_mail(subject=subject, message=message, from_email=from_email, recipient_list=recipient_list, html_message=html_message)
